package Group9.TodoManager.Actions;

import Group9.TodoManager.Settings;
import java.awt.event.ActionEvent;
import javax.swing.Action;
import javax.swing.ImageIcon;

/**
 * ExitAction class is to handle exiting from the application.
 * @author volkan cambazoglu
 * @author Rupesh
 */
public class ExitAction<T> extends TodoManagerAction{

	/**
	 * Constructor. Creates an instance of ExitAction class
	 * @param name name of the action
	 * @param icon icon of the action
	 * @param mnemonic mnemonic of the action
	 * @param toolTipText tool tip of the action
	 */
    public ExitAction(String name, ImageIcon icon, int mnemonic,
                                                String toolTipText){
        super(name, icon);
        putValue(Action.SHORT_DESCRIPTION, toolTipText);
        putValue(Action.MNEMONIC_KEY, mnemonic);
    }

    /**
     * When this method will be executed, it will call the method that stores 
     * properties of the application.
     * @param e event
     */
    @Override
    public void actionPerformed(ActionEvent e){
        executeAction(e);
    }

    /**
     * Store properties of the application
     * @param param event
     */
    @Override
    public void executeAction(Object param) {
        Settings.flushProperties();
        System.exit(0);
    }
}
